﻿<UserControl x:Class="KBS.FamilyLines.Controls.FamilyView.FamilyViewViewer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:KBS.FamilyLines.Controls.FamilyView"
             xmlns:FamilyLines="clr-namespace:KBS.FamilyLines"
             xmlns:Properties="clr-namespace:KBS.FamilyLines.Properties" mc:Ignorable="d" 
             d:DesignHeight="300" 
             d:DesignWidth="500"
             >
    
    <UserControl.Resources>
        <FamilyLines:DateFormattingConverter x:Key="DateConvert"/>
        <FamilyLines:BoolToVisibilityConverter x:Key="VisiConvert"/>
        <FamilyLines:ComposingConverter x:Key="ComposingConverter">
            <FamilyLines:ComposingConverter.Converters>
                <FamilyLines:NotConverter />
                <FamilyLines:BoolToVisibilityConverter />
            </FamilyLines:ComposingConverter.Converters>
        </FamilyLines:ComposingConverter>
    </UserControl.Resources>
    
    <Grid>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/> <!-- label -->
            <RowDefinition Height="Auto"/> <!-- grandparents buttons -->
            <RowDefinition Height="Auto"/> <!-- married persons -->
            <RowDefinition Height="Auto"/> <!-- label -->
            <RowDefinition Height="*"/>    <!-- children -->
        </Grid.RowDefinitions>

        <TextBlock Text="{x:Static Properties:Resources.Parents}"
                   Grid.Row="0" 
                   Style="{DynamicResource SectionHeaderStyle}"
                   HorizontalAlignment="Center" 
                   Margin="0,5,0,5"
                   />

        <!-- GrandParents buttons -->
        <DockPanel Grid.Row="1">
            <StackPanel Orientation="Horizontal" DockPanel.Dock="Left">
                <local:GParentView x:Name="GDad1" Father="true" Margin="5"/>
                <local:GParentView x:Name="GMum1" Father="false" Margin="5"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" DockPanel.Dock="Right" HorizontalAlignment="Right">
                <local:GParentView x:Name="GDad2" Father="true" Margin="5"/>
                <local:GParentView x:Name="GMum2" Father="false" Margin="5"/>
            </StackPanel>
        </DockPanel>

        <!-- Parents / Marriage -->
        <Border Grid.Row="2" 
                BorderBrush="White" 
                BorderThickness="1" 
                CornerRadius="10" 
                >
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
            
                <local:PersonView Grid.Column="0" x:Name="dad" Child="False" SpouseColumn="0"/>

                <!-- Marriage details -->
                <Border Grid.Column="1" 
                        Visibility="{Binding Path=IsMarried, Mode=OneWay, Converter={StaticResource VisiConvert}}"
                        CornerRadius="10" 
                        BorderThickness="1"
                        ToolTip="{x:Static Properties:Resources.ClickMarriageDetail}"
                        MouseUp="Marriage_Click"
                        Background="{DynamicResource PanelGradientBrush}"
                        Height="{Binding ActualHeight, ElementName=MarrStack}"
                        >
                    
                    <StackPanel VerticalAlignment="Center" 
                                x:Name="MarrStack" 
                                Margin="5"
                                >
                        <StackPanel Orientation="Horizontal" Margin="0,5,0,0">
                            <Label Padding="0" 
                                   Margin="2,0,5,0"
                                   Content="{x:Static Properties:Resources.Marriage}"
                                   />
                            <Label Padding="0" 
                                   Content="{Binding Path=MarrDate, Mode=OneWay, Converter={StaticResource DateConvert}}"
                                   />
                        </StackPanel>
                        <Label Padding="0" Content="{Binding Path=MarrPlace, Mode=OneWay}"/>
                        <StackPanel Orientation="Horizontal"
                                    Visibility="{Binding Path=IsDivorced, Mode=OneWay, Converter={StaticResource VisiConvert}}"
                                    Margin="0,5,0,0">
                            <Label Padding="0" 
                                   Margin="2,0,5,0"
                                   Content="{x:Static Properties:Resources.Divorce}"
                                   />
                            <Label Padding="0" Content="{Binding Path=DivDate, Mode=OneWay, Converter={StaticResource DateConvert}}"/>
                        </StackPanel>
                        <Label Padding="0" Content="{Binding Path=DivPlace, Mode=OneWay}"/>
                    </StackPanel>
                </Border>

                <local:PersonView Grid.Column="2" x:Name="mum" Child="False" 
                                  SpouseColumn="2"
                                  Visibility="{Binding Path=IsMarried, Mode=OneWay, Converter={StaticResource VisiConvert}}"
                                  />
                <Button x:Name="AddSpouse"
                        Grid.Column="2"
                        MinWidth="120"
                        Click="AddSpouse_Click"
                        Content="{x:Static Properties:Resources.AddNewSpouse}"
                        Visibility="{Binding Path=IsMarried, Mode=OneWay, Converter={StaticResource ComposingConverter}}"
                        />
                        
            </Grid>
        </Border>

        <!-- Label -->
        <TextBlock Text="{x:Static Properties:Resources.Children}" 
                   Grid.Row="3" 
                   Style="{DynamicResource SectionHeaderStyle}"
                   HorizontalAlignment="Center" 
                   Margin="0,5,0,5"
                   />

        <!-- Children -->
        <Border Grid.Row="4" 
                Style="{DynamicResource BorderStyle}"
                BorderBrush="#FFFFFFFF" 
                BorderThickness="1" CornerRadius="10" 
                Background="{DynamicResource PanelGradientBrush}"
                >
            <ScrollViewer HorizontalScrollBarVisibility="Visible" 
                          VerticalScrollBarVisibility="Hidden">
                <StackPanel Name="ChildRow" Orientation="Horizontal">
                    <Border x:Name="ChildOps"
                            Background="{DynamicResource PanelGradientBrush}"
                            Style="{DynamicResource BorderStyle}"
                            BorderBrush="#FFFFFFFF" 
                            BorderThickness="1,1,1,1" 
                            CornerRadius="10,10,10,10"
                            >
                            <StackPanel Orientation="Vertical"
                                        MinHeight="100"
                                        MinWidth="100"
                                        >
                                <Button x:Name="AddSon" 
                                        Content="{x:Static Properties:Resources.AddSon}"
                                        Click="AddSon_Click"
                                        Margin="0,20,0,5"
                                        />
                                <Button x:Name="AddDau" 
                                        Click="AddDau_Click"
                                        Content="{x:Static Properties:Resources.AddDaughter}"
                                        />
                            </StackPanel>
                    </Border>
                </StackPanel>
            </ScrollViewer>
        </Border>

    </Grid>
    
</UserControl>
